package com.xiaorun.portal.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaorun.portal.dao.EnterpriseMapper;
import com.xiaorun.portal.dao.NewsMapper;
import com.xiaorun.portal.modal.Bo.Query;
import com.xiaorun.portal.modal.Vo.Enterprise;
import com.xiaorun.portal.modal.Vo.News;
import com.xiaorun.portal.service.IEnterpriseService;
import com.xiaorun.portal.service.INewsService;
import com.xiaorun.portal.utils.TaleUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.FileCopyUtils;

import javax.xml.bind.DatatypeConverter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by BlueT on 2018/3/3.
 */
@Service
@Slf4j
public class EnterpriseServiceImpl implements IEnterpriseService {

    @Autowired
    private EnterpriseMapper enterpriseMapper;

    @Override
    public int batchSave(List<Enterprise> enterpriseList) {
        int result = enterpriseMapper.batchSave(enterpriseList);
        return result;
    }

    @Override
    public PageInfo<Enterprise> list(int pageNum, int pageSize, Map<String, Object> params) {
        PageHelper.startPage(pageNum, pageSize);
        //Page<?> page = PageHelper.startPage([pageNum],[pageSize],[iscount]);
        //List<?> pagelist = queryForList( xxx.class , "queryAll" , param);
        //long count = page.getTotal();
        Query query = new Query(params != null ? params: new HashMap<>());
        List<Enterprise> enterpriseList = enterpriseMapper.list(query);
        PageInfo<Enterprise> pageInfo = new PageInfo(enterpriseList);
        return pageInfo;
    }


}
